<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/1/14
 * Time: 12:44
 */

Class articleRelationModel extends RelationModel{
    protected $tableName = "article";
    protected $_link = array(
        "article_type" =>array(
           'mapping_type'=>BELONGS_TO,
           'class_name'=>'article_type',
           'foreign_key'=>'cid',
           'mapping_name'=>'article_type'
        ),
    );

    /**
     * 获得单条数据
     * @param $condition 条件
     * @return mixed
     */
    public function getArticleByOne($condition,$field){
        return $this->where($condition)->field($field)->find();
    }

    /**
     * 获得多条数据
     * @param $condition 条件
     * @param $field 字段
     * @param $order 排序
     * @param $limit 数量
     * @return mixed
     */
    public function getArticleByMore($condition,$field,$order,$limit){
        return $this->where($condition)->field($field)->order($order)->limit($limit)->select();
    }

}